<template>
  <div>
    <el-select v-model="value" placeholder="请选择加入年份" filterable @change="joinYearChange">
      <el-option
        v-for="item in joinYear"
        :key="item.id"
        :label="item.value"
        :value="item.id">
      </el-option>
    </el-select>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'joinYear',
  data () {
    return {
      joinYear: [ { id: 0, value: '全部' }, { id: -1, value: '未加入' } ],
      value: ''
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  mounted () {
    this.$store.dispatch('SetJoinYear', 0)
    let joinYear = []
    let currentYear = new Date().getFullYear()
    for (let i = 2000; i <= currentYear; i++) {
      joinYear.push({ id: i, value: i })
    }
    this.joinYear = [ { id: 0, value: '全部' }, { id: -1, value: '未加入' } ].concat(joinYear)
  },
  methods: {
    joinYearChange (selVal) {
      this.$store.dispatch('SetJoinYear', selVal)
    }
  }
}
</script>

<style scoped>

</style>
